
/**
 * Record pre-insert trigger.
 * Validate the record to be inserted.
 * When false is returned the record will not be inserted in the database.
 * When an exception is thrown the record will also not be inserted in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/contable/limbo>} record record that will be inserted
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"5C26E51D-12DA-48CC-B0D9-A07C7DDCA9BD"}
 */
function onLimboRecordInsert(record) {
	
	var $imp_carga
//	if (record.limbo_to_limbo_cab.moneda_carga == 1) // 1-Pesos 2-Dolares
	if (globals.gMonedaCarga == 1) // 1-Pesos 2-Dolares
	{
		$imp_carga = record.importe
	}
	else
	{
		$imp_carga = record.impodol
	}

	if (record.columna == "D")
	{	
		record.importe_haber 		= null;
		record.importe_debe 		= $imp_carga
		record.haber_pesos 			= null
		record.haber_dolar 			= null
		record.debe_pesos 			= record.importe
		record.debe_dolar 			= record.impodol
	}
	else
	{
		record.importe_haber 		= $imp_carga
		record.importe_debe 		= null
		record.haber_pesos 			= record.importe
		record.haber_dolar 			= record.impodol	
		record.debe_pesos 			= null
		record.debe_dolar 			= null
	}
	record.cuenta_nombre_impresion 	= record.limbo_to_cuentas_impresion.cuenta_impresion;
	record.cuenta_impresion 		= record.limbo_to_cuentas_impresion.cuenta_impresion;
	return true
}
